package cn.pku.sirx.snad.ad.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import cn.pku.sirx.snad.ad.dao.IBusinessKeywordDao;
import cn.pku.sirx.snad.ad.model.entity.BusinessKeyword;

/**
 * @author WangXiao
 */
public class BusinessKeywordDaoImpl extends DaoImpl<BusinessKeyword> implements
		IBusinessKeywordDao {

	public BusinessKeywordDaoImpl() {
		super(BusinessKeyword.class);
	}

	@Override
	public Integer getWeight(String keyword) {
		DetachedCriteria criteria = DetachedCriteria.forClass(targetClass);
		criteria.add(Restrictions.eq("keyword", keyword));
		List<BusinessKeyword> businessKeywords = get(criteria);
		return businessKeywords.isEmpty() ? null : businessKeywords.get(0)
				.getWeight();
	}

}
